package com.hsoft.zhxy.app.xtgl_02_01.service.impl;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hsoft.zhxy.app.common.model.entity.JcggDlrz;
import com.hsoft.zhxy.app.xtgl_02_01.mapper.JcggDlrzMapper;
import com.hsoft.zhxy.app.xtgl_02_01.model.vo.DlrzVO;
import com.hsoft.zhxy.app.xtgl_02_01.service.JcggDlrzService;
import com.hsoft.zhxy.common.base.BaseService;
import com.hsoft.zhxy.common.result.ResultBody;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

 /**
 * All rights Reserved, Designed By 哈尔滨工业大学软件工程股份有限公司
 * 
 * @Title: 登录日志 Service层接口实现类
 * @Package 
 * @Description: 
 * @author: system
 * @date: 2020-10-26
 */
@Log4j2
@Service
public class JcggDlrzServiceImpl extends BaseService implements JcggDlrzService {

    @Autowired
    private JcggDlrzMapper jcggDlrzMapper;


     /**
      * 查询分页数据
      * @param dlrzVO
      * @param page
      * @param pageSize
      * @return
      */
     public JSONObject findDlrzListByPage(DlrzVO dlrzVO, long page, long pageSize) {

         Page<DlrzVO> pageObj = new Page<DlrzVO>(page, pageSize);
         QueryWrapper<DlrzVO> queryWrapper = new QueryWrapper<DlrzVO>();

         queryWrapper.like(!StringUtils.isBlank(dlrzVO.getYhid()),"yhid", dlrzVO.getYhid())
                 .like(!StringUtils.isBlank(dlrzVO.getXm()),"xm",dlrzVO.getXm())
                 .eq(StringUtils.isNotBlank(dlrzVO.getSfms()) ,"sfms" , dlrzVO.getSfms())
                 .eq(dlrzVO.getDllx() != null,"dllx" , dlrzVO.getDllx())
                 .ge(dlrzVO.getKssj()!=null,"czsj",dlrzVO.getKssj())
                 .le(dlrzVO.getJssj()!=null,"czsj",dlrzVO.getJssj())
                 .orderByDesc("czsj");

         IPage<JcggDlrz> result = jcggDlrzMapper.findDlrzListByPage(pageObj, queryWrapper);
         return ResultBody.setData(result.getTotal(), result.getRecords());
     }


}
